package cn.net.isir.controller.manager;

import cn.net.isir.common.ResultObject;
import cn.net.isir.entity.Factor;
import cn.net.isir.service.FactorService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author liuxubo
 * @filename Commission.java
 * @package cn.net.isir.controller.manager
 * @email lxb@isir.net.cn
 * @date 2019/02/26
 * @comment
 * @since 1.8
 */
@RestController
@RequestMapping("/commission")
public class CommissionController {
    @Resource
    private FactorService factorService;

    /**
     * 查询佣金系数
     *
     * @return 返回佣金系数
     */
    @RequestMapping(value = "/query", method = RequestMethod.GET)
    public ResultObject query() {
        return new ResultObject(200, "success", factorService.selectOne(null));
    }

    /**
     * 保存佣金系数
     *
     * @param factor 系数实体类
     * @return 修改结果：0表示失败，1表示成功
     */
    @RequestMapping(value = "/save", method = RequestMethod.PUT)
    public ResultObject save(@RequestBody Factor factor) {
        return new ResultObject(200, "success", factorService.update(factor));
    }
}
